;(function($,window){
	if(!$ || !window){
		return ;
	}
	
	$.fn.windowCloseUtil = function(basePath){
		
		    var bPath =  "windowutil/";
		    
			var userAgent = navigator.userAgent; //åå¾æµè§å¨çuserAgentå­ç¬¦ä¸²  
			var isOpera = userAgent.indexOf("Opera") > -1; //å¤æ­æ¯å¦Operaæµè§å¨  
			var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //å¤æ­æ¯å¦IEæµè§å¨
			var isIE11 = userAgent.indexOf("rv:11.0") > -1; //å¤æ­æ¯å¦æ¯IE11æµè§å¨
			var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //å¤æ­æ¯å¦IEçEdgeæµè§å¨

			
			if(!isIE && !isEdge && !isIE11) {//å¼å®¹chromeåfirefox
				var _beforeUnload_time = 0, _gap_time = 0;
				var is_fireFox = navigator.userAgent.indexOf("Firefox")>-1;//æ¯å¦æ¯ç«çæµè§å¨
				window.onunload = function (){
					_gap_time = new Date().getTime() - _beforeUnload_time;
					if(_gap_time <= 5){
						$.post(bPath+'delSession',"",function(data){});//æµè§å¨å³é­
					}else{//æµè§å¨å·æ°
					}
			 	}
				window.onbeforeunload = function (){ 
					_beforeUnload_time = new Date().getTime();
					if(is_fireFox){//ç«çå³é­æ§è¡
						$.post(bPath+'delSession',"",function(data){});//æµè§å¨å³é­
					} 
				};
			}

			if(isIE) {//å¼å®¹ie8,9,10
				window.onbeforeunload = function() {
					//alert(0);
					flagiii = "1";
					$.ajax({
						type: "post",
						url: bPath+"A",
						data:{"flagiii": flagiii},
						success: function() {
			 
						},
						async:false
					});
							
				}
				window.onunload = onclose;
				function onclose(){
					flagiii = "0";
					$.ajax({
						type: "post",
						url: bPath+"storageData",
						data:{"flagiii": flagiii},
						success: function() {
								
						}
					});
				}
			}

			var flagiii = "0";
			function onloadFun() {
				$.ajax({
			 		type: "post",
			 		url: bPath+"storageData",
			 		data:{"flagiii": flagiii},
			 		success: function() {
								
			 		}
			 	});
			}
				    
			if(isIE || isIE11 || isEdge) {
				//é¡µé¢å è½½è¿æ¥åå°flagiiå­å¥session 
				onloadFun();
			}	
				
			if(isIE11 || isEdge) {//å¼å®¹ie11 edge
				window.onbeforeunload = function() {
					flagiii = "1";
					$.ajax({
						type: "post",
						url: bPath+"storageData",
						data:{"flagiii": flagiii},
						success: function() {
									
						},
						async:false
					});
				}
				window.onunload = onclose;
				function onclose(){
					$.ajax({
						type: "post",
						url: bPath+"delSessionData",
						data: {"rnd": Math.random()},
						success: function() {
									
						}
					});
				}
			}
	}

})(jQuery,window);